import myAxios from "@/request";
import type {
  BalanceAlarmQueryRequest,
  BalanceAlarmAddRequest,
  BalanceAlarmUpdateRequest,
  DeleteRequest,
} from "../models/balanceAlarm";

/**
 * 分页获取余额报警记录列表
 * @param params
 */
export const listBalanceAlarmByPage = async (
  params: BalanceAlarmQueryRequest
) => {
  return myAxios.post("/api/balanceAlarm/list/page", params);
};
export const listBalanceAlarmByPageVo = async (
  params: BalanceAlarmQueryRequest
) => {
  return myAxios.post("/api/balanceAlarm/list/page/vo", params);
};
/**
 * 添加余额报警记录
 * @param params
 */
export const addBalanceAlarm = async (params: BalanceAlarmAddRequest) => {
  return myAxios.post("/api/balanceAlarm/add", params);
};

/**
 * 更新余额报警记录
 * @param params
 */
export const updateBalanceAlarm = async (params: BalanceAlarmUpdateRequest) => {
  return myAxios.post("/api/balanceAlarm/update", params);
};

/**
 * 删除余额报警记录
 * @param params
 */
export const deleteBalanceAlarm = async (params: DeleteRequest) => {
  return myAxios.post("/api/balanceAlarm/delete", params);
};

// 定义获取宿舍余额告警数量的函数
export const getBalanceAlarmCountByDormitoryId = async (dormitoryId: any) => {
  return myAxios.request({
    url: `/api/balanceAlarm/get/count`,
    method: "GET",
    params: {
      dormitoryId,
    },
  });
};
/**
 * 根据 id 获取余额报警记录
 * @param id
 */
export const getBalanceAlarmById = async (id: number) => {
  return myAxios.get(`/api/balanceAlarm/get/vo?id=${id}`);
};

/**
 * 获取当前用户创建的余额报警记录列表
 * @param params
 */
export const listMyBalanceAlarmByPage = async (
  params: BalanceAlarmQueryRequest
) => {
  return myAxios.post("/api/balanceAlarm/my/list/page/vo", params);
};

/**
 * 编辑余额报警记录（用户）
 * @param params
 */
export const editBalanceAlarm = async (params: BalanceAlarmUpdateRequest) => {
  return myAxios.post("/api/balanceAlarm/edit", params);
};
